<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>我的博客 - 首页</title>
  <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<!-- 导航栏 -->
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
  <div class="container">
    <a class="navbar-brand" href="${pageContext.request.contextPath}/webapp/index.jsp">我的博客</a>

    <div class="collapse navbar-collapse">
      <ul class="navbar-nav me-auto">
        <li class="nav-item">
          <a class="nav-link active" href="#">首页</a>
        </li>
        <li class="nav-item">
          <a class="nav-link" href="#">文章分类</a>
        </li>
        <li class="nav-item">
          <a class="nav-link" href="#">关于我</a>
        </li>
      </ul>

      <ul class="navbar-nav">
        <c:if test="${loginUser != null}">
          <!-- 已登录状态 -->
          <li class="nav-item dropdown">
            <a class="nav-link dropdown-toggle" href="#" id="userDropdown" role="button"
               data-bs-toggle="dropdown" aria-expanded="false">
                ${loginUser.nickname}
            </a>
            <ul class="dropdown-menu" aria-labelledby="userDropdown">
              <li><a class="dropdown-item" href="#">个人中心</a></li>
              <li><a class="dropdown-item" href="#">发布文章</a></li>
              <li><hr class="dropdown-divider"></li>
              <li><a class="dropdown-item" href="${pageContext.request.contextPath}/logout">退出登录</a></li>
            </ul>
          </li>
        </c:if>
        <c:if test="${loginUser == null}">
          <!-- 未登录状态 -->
          <li class="nav-item">
            <a class="nav-link" href="${pageContext.request.contextPath}/login">登录</a>
          </li>
        </c:if>
      </ul>
    </div>
  </div>
</nav>

<!-- 主要内容区 -->
<div class="container mt-4">
  <div class="jumbotron">
    <h1 class="display-4">欢迎来到我的博客！</h1>
    <p class="lead">这是一个使用JavaWeb技术开发的简易博客系统，包含文章发布、分类管理等功能。</p>
    <hr class="my-4">

    <c:if test="${loginUser != null}">
      <p>当前登录用户：${loginUser.nickname}</p>
      <a class="btn btn-primary btn-lg" href="${pageContext.request.contextPath}/article/edit" class="btn btn-primary" role="button">开始写作</a>
    </c:if>

    <c:if test="${loginUser == null}">
      <p>请先登录后使用完整功能</p>
      <a class="btn btn-primary btn-lg" href="${pageContext.request.contextPath}/login" role="button">去登录</a>
    </c:if>
  </div>
</div>

<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>